﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using EntityBinder.Attribute;
using EntityBinder.Interface;
using EntityBinder.Binder;
using EntityBinder.Transformer;
using EntityBinder;

namespace UnitTest.Model
{
	[Entity(Identifier="SimpleContainer")]
	class SimpleContainer
	{
		[DataEntity(Identifier="my_bool")]
		public bool m_bool = false;

		[DataEntity(Identifier="my_char")]
		public char m_char = '*';

		[DataEntity(Identifier="my_double")]
		public double m_double = 0.0;

		[DataEntity(Identifier="my_float")]
		public float m_float = 0.0f;

		[DataEntity(Identifier="my_int")]
		public int m_int = 42;

		[DataEntity(Identifier="my_long")]
		public long m_long = 79;

		[DataEntity(Identifier="my_str")]
		public string m_str = null;

		#region test set

		public static SimpleContainer TestData1()
		{
			return new SimpleContainer()
			{
				m_bool = true,
				m_char = 'p',
				m_double = 51.42,
				m_float = 69.73f,
				m_int = 4242,
				m_long = 12345,
				m_str = "hello"
			};
		}

		public static SimpleContainer TestData2()
		{
			return new SimpleContainer()
			{
				m_bool = false,
				m_char = 'o',
				m_double = 51.87,
				m_float = 61.73f,
				m_int = 422,
				m_long = 145,
				m_str = "world"
			};
		}

		#endregion

		public static IEntityElement GetRules()
		{
			IEntityElement root = new EntityElement("SimpleContainer", new ObjectBinder<SimpleContainer>(), null);
			root.AddChildren(
				new EntityElement("my_bool", new ContentBinder(new BoolTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_bool")),
				new EntityElement("my_char", new ContentBinder(new CharTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_char")),
				new EntityElement("my_double", new ContentBinder(new DoubleTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_double")),
				new EntityElement("my_float", new ContentBinder(new FloatTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_float")),
				new EntityElement("my_int", new ContentBinder(new IntTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_int")),
				new EntityElement("my_long", new ContentBinder(new LongTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_long")),
				new EntityElement("my_str", new ContentBinder(new StringTransformer()), MemberAccessFactory.FromType<SimpleContainer>("m_str"))
			);
			return root;
		}
	}
}
